package com.burst.reptile.modular.zp.warpper;

import java.util.List;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.burst.reptile.common.utils.DateUtil;
import com.burst.reptile.common.utils.NumberUtils;
import com.burst.reptile.common.utils.ToolUtil;
import com.burst.reptile.framework.constant.ConstantFactory;
import com.burst.reptile.framework.web.warpper.BaseControllerWrapper;
import com.burst.reptile.modular.zp.entity.ZpCollect;
import com.burst.reptile.modular.zp.entity.ZpResources;

public class ZpCollectWrapper extends BaseControllerWrapper<ZpCollect> {

    public ZpCollectWrapper(Page<ZpCollect> page) {
        super(page);
    }
    
    public ZpCollectWrapper(List<ZpCollect> list) {
        super(list);
    }
    
    @Override
    protected void wrapTheMap(ZpCollect collect) {
    	Long articleId = collect.getArticleId();
    	ZpResources resources = ConstantFactory.me().getResources(articleId);
    	if(ToolUtil.isNotEmpty(resources)) {
    		collect.setTitle(resources.getTitle());
    		collect.setSummary(resources.getSummary());
    		collect.setCoverImage(resources.getCoverImage());
    		collect.setCoverVideo(resources.getCoverVideo());
    		collect.setReadSize(NumberUtils.amountConversion(resources.getReadSize()));
    		collect.setVoteSize(NumberUtils.amountConversion(resources.getVoteSize()));
    		collect.setUser(ConstantFactory.me().getUser(resources.getUserId()));
    	}
    	collect.setTime(DateUtil.timeToFormat(collect.getCreateTime()));
    }

}
